import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* 侧边栏布局组件 */
import Layout from '@/layout'



/**
 *注意：子菜单仅在路由children.length >= 1时出现
 *详情参见：https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 *hide: true 如果设置为 true，项目将不会显示在侧边栏中（默认为 false）
 *alwaysShow: true 如果设置为 true，将始终显示根菜单
 *如果没有设置alwaysShow，当item有多个子路由时，
*会变成嵌套模式，否则不显示根菜单
 *重定向：noRedirect 如果设置 noRedirect 将不会在面包屑中重定向
 *name:'router-name' 该名称由<keep-alive>使用（必须设置！！！）
 *元：{
    Roles: ['admin','editor']控制页面角色（可以设置多个角色）
    title: 'title' 显示在侧边栏和面包屑中的名称（推荐设置）
icon: 'svg-name'/'el-icon-x' 图标显示在侧边栏中
    breadcrumb: false 如果设置为 false，该项目将隐藏在面包屑中（默认为 true）
    activeMenu: '/example/list' 如果设置路径，侧边栏将突出显示您设置的路径
  }
 */





/**
 * 常量路由
 * 没有权限要求的基本页面
 * 所有角色均可访问
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/index',
    children: [
      {
        path: 'index',
        name: 'index',
        component: () => import('@/views/index/index'),
        meta: { title: '首页', icon: 'el-icon-s-home' }
      },
    ]
  },

  {
    path: '/reportManagement',
    component: Layout,
    meta: { title: '报告管理', icon: 'el-icon-picture' },
    redirect: '/reportManagement/accompanyingReport',
    children: [
      {
        path: 'accompanyingReport',
        name: 'accompanyingReport',
        component: () => import('@/views/reportManagement/accompanyingReport'),
        meta: { title: '陪跑报告', icon: 'el-icon-picture-outline' }
      },
      {
        path: 'bigDataReport',
        name: 'bigDataReport',
        component: () => import('@/views/reportManagement/bigDataReport'),
        meta: { title: '大数据报告', icon: 'el-icon-picture-outline' }
      },
      {
        path: 'taxReport',
        name: 'taxReport',
        component: () => import('@/views/reportManagement/taxReport'),
        meta: { title: '税务报告', icon: 'el-icon-picture-outline' }
      }
    ]
  },

  {
    path: '/financialManagement',
    component: Layout,
    meta: { title: '财务管理', icon: 'el-icon-picture' },
    redirect: '/financialManagement/withdrawalList',
    children: [
      {
        path: 'withdrawalList',
        name: 'withdrawalList',
        component: () => import('@/views/financialManagement/withdrawalList'),
        meta: { title: '提现列表', icon: 'el-icon-picture-outline' }
      },
      {
        path: 'orderList',
        name: 'orderList',
        component: () => import('@/views/financialManagement/orderList'),
        meta: { title: '订单列表', icon: 'el-icon-picture-outline' }
      }
    ]
  },

  {
    path: '/customerManagement',
    component: Layout,
    meta: { title: '客户管理', icon: 'el-icon-picture' },
    redirect: '/customerManagement/customerList',
    children: [
      {
        path: 'customerList',
        name: 'customerList',
        component: () => import('@/views/customerManagement/customerList'),
        meta: { title: '客户列表', icon: 'el-icon-picture-outline' }
      },
      {
        path: 'followUpList',
        name: 'followUpList',
        component: () => import('@/views/customerManagement/followUpList'),
        meta: { title: '跟进列表', icon: 'el-icon-picture-outline' }
      }
    ]
  },

  {
    path: '/customerService',
    component: Layout,
    meta: { title: '客服管理', icon: 'el-icon-picture' },
    redirect: '/customerManaging/customerService',
    children: [
      {
        path: 'customerService',
        name: 'customerService',
        component: () => import('@/views/systemConfiguration/customerService'),
        meta: { title: '客服列表', icon: 'el-icon-picture-outline' }
      },
    ]
  },

  {
    path: '/systemConfiguration',
    component: Layout,
    meta: { title: '配置管理', icon: 'el-icon-picture' },
    redirect: '/systemConfiguration/systemConfiguration',
    children: [
      {
        path: 'systemConfiguration',
        name: 'systemConfiguration',
        component: () => import('@/views/systemConfiguration/systemConfiguration'),
        meta: { title: '系统配置', icon: 'el-icon-picture-outline' }
      }
    ]
  },

    {
    path: '/changePassword',
    component: Layout,
    redirect: '/changePassword',
    children: [
      {
        path: 'changePassword',
        name: 'changePassword',
        component: () => import('@/views/login/changePassword'),
        meta: { title: '修改密码', icon: 'el-icon-menu' }
      }
    ]
  },

  


  // {
  //   path: '/example',
  //   component: Layout,
  //   redirect: '/example/table',
  //   name: 'Example',
  //   meta: { title: 'Example', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'table',
  //       name: 'Table',
  //       component: () => import('@/views/table/index'),
  //       meta: { title: 'Table', icon: 'table' }
  //     },
  //     {
  //       path: 'tree',
  //       name: 'Tree',
  //       component: () => import('@/views/tree/index'),
  //       meta: { title: 'Tree', icon: 'tree' }
  //     }
  //   ]
  // },

  // 404页面一定要放在最后！！！
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()



export function resetRouter() {
  const newRouter = createRouter()
  // 重置路由器
  router.matcher = newRouter.matcher
}

export default router
